import 'package:flutter/material.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("按钮"), // 标题
          leading: Icon(Icons.menu), // 左侧图标
          actions: [Icon(Icons.settings)],  // 右侧图标数组
          elevation: 0.0,// 去掉阴影
          centerTitle: true, // 标题居中

        ),
        body:ButtonDemo(),
        // 漂浮按钮
        floatingActionButton: FloatingActionButton(
          onPressed: (){},
          tooltip: 'Increment',
          child: Icon(Icons.add),
          backgroundColor: Colors.green,
          elevation: 0,
        ),
    );
  }
}

class ButtonDemo extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10),
      child: Wrap(
        children: [
          TextButton(
              onPressed: (){
                print('点击TextButton');
              },
              onLongPress: (){
                print("长按TextButton");
              },
              child: Text("TextButton")
          ),
          ElevatedButton(
              onPressed: (){
                print('点击ElevatedButton');
              },
              onLongPress: (){
                print("长按ElevatedButton");
              },
              child: Text("ElevatedButton")
          ),
          OutlinedButton(
              onPressed: (){
                print('点击OutlineButton');
              },
              onLongPress: (){
                print("长按OutlineButton");
              },
              child: Text("轮廓按钮"),
              style: ButtonStyle(
                textStyle: MaterialStateProperty.all(
                  TextStyle(
                    fontSize: 30,
                  )
                ),
                foregroundColor: MaterialStateProperty.resolveWith((states) => null),
                shadowColor: MaterialStateProperty.all(Colors.yellow),
                elevation: MaterialStateProperty.all(20),
                side: MaterialStateProperty.all(
                 BorderSide(
                   color: Colors.green,
                   width:2
                 )
                ),
                // 声明按钮形状
                shape: MaterialStateProperty.all(
                  StadiumBorder(
                    side: BorderSide(
                      color:Colors.green,
                      width:2,
                    )
                  )
                ),
                // 设置按钮大小
                minimumSize: MaterialStateProperty.all(Size(150, 60)),
                // 水波纹
                overlayColor: MaterialStateProperty.all(Colors.purple),
              ),
          ),
          // 图标按钮
          IconButton(
              icon: Icon(Icons.add_alarm),
              onPressed: (){
                print("IconButton");
              },
             color:Colors.red,
            splashColor: Colors.lightBlue, // 水波纹
            //highlightColor: Colors.purple, // 高亮
            tooltip: "怎么了", // 提示
          ),
          TextButton.icon(
              onPressed: null,
              icon: Icon(Icons.add_circle),
              label: Text("文本按钮"),

          ),
          ElevatedButton.icon(
            onPressed: null,
            icon: Icon(Icons.add_circle),
            label: Text("凸起按钮"),
          ),
          OutlinedButton.icon(
              onPressed: null,
              icon: Icon(Icons.add_circle),
              label: Text("轮廓按钮")
          ),
          Container(
            color:Colors.pink[100],
            width: double.infinity,
            child: ButtonBar(
              children: [
                ElevatedButton(onPressed: null, child: Text('按钮1')),
                ElevatedButton(onPressed: null, child: Text('按钮2')),
                ElevatedButton(onPressed: null, child: Text('按钮3')),
                ElevatedButton(onPressed: null, child: Text('按钮4')),
              ],
            ),
          ),
          BackButton(
            color: Colors.red,
            onPressed: (){},
          ),
          CloseButton(
            color:Colors.red,
          )
        ],
      ),
    );
  }
}
